import axios from 'axios';

//吹风机使用记录列表
export const endbackfindAll = (params?: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/usage-records/findAll', config);
};

//分页查询设备列表
export const devicfindAll = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/devices/end_back/findAll', config);
};

//注意事项列表
export const announcementsfindAll = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/announcements/wechat/findEnabled', config);
};

//新增注意事项
export const announcementsadd = (data: any) => {
  return axios.post('/blow/announcements/end_back/add', data);
};

//编辑注意事项
export const announcementsupdate = (id: string | number, data: any) => {
  return axios.put(`/blow/announcements/end_back/update/${id}`, data);
};

//分页查询所有快捷时长选项
export const quickdurationsfindAll = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/quick_durations/findAll', config);
};

//新增快捷时长
export const quickdurationsadd = (data: any) => {
  return axios.post('/blow/quick_durations/end_back/add', data);
};

//查询时长
export const quick_urationsid = (id: any) => {
  return axios.get(`/blow/quick_durations/end_back/find/${id}`, {});
};

//修改时长
export const quick_durationsupdate = (id: string | number, data: any) => {
  return axios.put(`/blow/quick_durations/end_back/update/${id}`, data);
};

//删除时长
export const quick_durationsdelete = (id: string | number, data: any) => {
  return axios.delete(`/blow/quick_durations/end_back/delete/${id}`, data);
};

//新增设备
export const devicesadd = (data: any) => {
  return axios.post(`/blow/devices/end_back/add`, data);
};

//通过设备的SN码获取设备信息
export const wechatfindByDeviceSn = (deviceId: any) => {
  return axios.get(`/blow/devices/wechat/findById`, {
    params: { deviceId }, // 自动转换为 URL 查询参数
  });
};

//修改设备
export const end_backupdate = (id: any, data: any) => {
  return axios.put(`/blow/devices/end_back/update/`, data);
};

//删除设备
export const devicesdelete = (id: string | number, data: any) => {
  return axios.delete(`/blow/devices/blowDevices/${id}`, data);
};

//分页查询 IMEI 记录
export const recordsfindAll = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/records/end_back/findAll', config);
};

//新增 IMEI 记录
export const recordsadd = (data: any) => {
  return axios.post(`/blow/records/end_back/add`, data);
};

//删除imei
export const recordsdelete = (id: any) => {
  return axios.delete(`/blow/records/end_back/delete/${id}`);
};

//获取imei详情
export const recordsfindid = (id: any) => {
  return axios.get(`/blow/records/end_back/find/${id}`, {});
};

//修改imei
export const recordsupdate = (id: any, data: any) => {
  return axios.put(`/blow/records/end_back/update/${id}`, data);
};

//统计接口--统计已支付订单总数与总金额（按开始-结束时间，可选）
export const recordsstats = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/usage-records/stats', config);
};

//统计接口--按天统计已支付订单消费总金额（开始-结束时间可选）
export const devicesitestats = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/stats/device-site-stats', config);
};

//统计接口—按天统计已支付订单消费总金额（开始-结束日期可选)
export const recordsdailyfee = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/usage-records/daily-fee', config);
};

//上传图片
export const repairsupload = (data: any) => {
  return axios.post(`/blow/repairs/upload`, data);
};

//导出使用记录（Excel 全量，流式 SXSSFWorkbook）
export const recordsexport = (params: any) => {
  const config = {
    params, // 自动转换为URL查询参数
    // responseType: 'blob' as const, // 确保正确处理二进制流
  };

  return axios.get('/blow/usage-records/export', config);
};

//根据业务订单号发起退款
export const paymentbyBusinessOrderNo = (data: any) => {
  return axios.post(
    `/payment/byBusinessOrderNo?businessOrderNo=${data.businessOrderNo}`,
    {}
  );
};

//分页查询维修记录
export const backfindAll = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/repair/end_back/findAll', config);
};

//删除维修记录
export const backdelete = (id: any) => {
  return axios.delete(`/blow/repair/end_back/delete/${id}`);
};

//修改维修记录
export const repairupdate = (id: any, data: any) => {
  return axios.put(`/blow/repair/end_back/update/${id}`, data);
};

//批量设置设备的使用时间段。
export const bulkusetime = (data: { deviceIds: string, useTime: string }) => {
  return axios.post(
    `/blow/devices/bulk-use-time?deviceIds=${encodeURIComponent(
      data.deviceIds
    )}&useTime=${encodeURIComponent(data.useTime)}`,
    null,
    {
      headers: {
        'Content-Type': 'application/json',
      },
    }
  );
};

//8-10统计接口--获取按天或按月的消费统计。
export const statsByDayOrMonth = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/blow/usage-records/statsByDayOrMonth', config);
};

//*****************************************************************************

//日汇总
export const thirdsyncthirdsync = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/api/thirdsync/stats', config);
};

//使用记录
export const thirdsyncorders = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/api/thirdsync/orders', config);
};

//营业额汇总统计
export const thirdsyncgroupstats = (params: any) => {
  const config = {
    params,
  };
  return axios.get('/api/thirdsync/group-stats', config);
};

//跳转登录
export const jumpLogin = (params: any) => {
  return axios.get('/api/saas/verify-user', { params });
};
